export default {
// 返回上一级
  goBack(delta = 1) {
    const canNavBack = getCurrentPages()
    if (canNavBack && canNavBack.length > 1) {
      uni.navigateBack({
        delta: delta
      })
    } else {
      history.back()
    }
  },

  // 弹出toast
  showToast(title, icon = 'success', duration = 1500) {
    return new Promise((resolve, reject) => {
      uni.showToast({
        title: title,
        icon: icon,
        duration: duration,
        fail: () => {
          reject()
        },
        complete: () => {
          resolve()
        }
      })
    })
  },

  // 弹出模态框
  showModal(title, content = '', showCancel = true) {
    return new Promise((resolve, reject) => {
      uni.showModal({
        title: title,
        content: content,
        showCancel: showCancel,
        fail: () => {
          reject()
        },
        success: (res) => {
          resolve(res)
        }
      })
    })
  }
}

